package com.fenxiangle.yueding.feature.order.model;

import com.fenxiangle.yueding.common.httprequestbody.HttpRequestBody;
import com.fenxiangle.yueding.entity.bo.OrderBo;
import com.fenxiangle.yueding.entity.bo.Page2Bo;
import com.fenxiangle.yueding.entity.bo.PageBo;
import com.fenxiangle.yueding.entity.bo.PayBo;
import com.fenxiangle.yueding.entity.bo.PublishBo;
import com.fenxiangle.yueding.entity.bo.PublishDemandBo;
import com.fenxiangle.yueding.entity.bo.TeamBo;
import com.fenxiangle.yueding.entity.bo.UserImageBo;
import com.fenxiangle.yueding.feature.order.contract.OrderContract;
import com.fenxiangle.yueding.feature.order.dependencies.order.DaggerOrderModelComponent;
import com.fenxiangle.yueding.feature.publish.contract.PublishContract;
import com.fenxiangle.yueding.feature.publish.dependencies.mine.DaggerPublishModelComponent;
import com.fenxiangle.yueding.framework.api.ApiLib;
import com.fenxiangle.yueding.framework.api.UserApi;
import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.entity.bo.Result;

import org.json.JSONObject;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;
import okhttp3.RequestBody;

public class OrderModel implements OrderContract.Model {

    @Inject
    UserApi api;


    @Inject
    public OrderModel() {
        DaggerOrderModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<List<PublishDemandBo>> getReceiveList(PageBo publishBo) {
        return api.getRecviceList(publishBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }


    @Override
    public Observable<List<PublishDemandBo>> getOrderList(Page2Bo publishBo) {
        return api.getOrderList(publishBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<List<PublishDemandBo>> sheetList(PageBo publishBo) {
        return api.sheetList(publishBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> acceptOrder(OrderBo payBo) {
        return api.acceptInvite(payBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> refuseOrder(OrderBo payBo) {
        return api.refuseInvite(payBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<UserImageBo> sheet(OrderBo payBo) {
        return api.sheet(payBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<UserImageBo> cancelSheet(PageBo payBo) {
        return api.cancelSheet(payBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<PublishBo> txOrder(OrderBo publishBo) {
        return api.toTxComment(publishBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> cancleOrder(OrderBo publishBo) {
        return api.cancleInviteOrder(publishBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<List<TeamBo>> getUserList(PageBo pageBo) {
        return api.getUserList(pageBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> confrimOrder(OrderBo publishBo) {
        return api.confrimOrder(publishBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> appeal(OrderBo publishBo) {
        return api.toweiqian(publishBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> toComment(JSONObject jsonObject) {
        RequestBody requestBody=HttpRequestBody.getRequestBody(jsonObject);
        return api.toComment(requestBody).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
